package com.tancire.web.controller.company;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tancire.common.annotation.Log;
import com.tancire.common.core.controller.BaseController;
import com.tancire.common.core.domain.AjaxResult;
import com.tancire.common.enums.BusinessType;
import com.tancire.net.domain.ShopTask;
import com.tancire.net.service.IShopTaskService;
import com.tancire.common.utils.poi.ExcelUtil;
import com.tancire.common.core.page.TableDataInfo;

/**
 * 任务管理Controller
 *
 * @author chenchao
 * @date 2023-12-25
 */
@RestController
@RequestMapping("/net/shopTask")
public class ShopTaskController extends BaseController {
    @Resource
    private IShopTaskService shopTaskService;

    /**
     * 查询任务管理列表
     */
    @PreAuthorize("@ss.hasPermi('net:shopTask:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShopTask shopTask) {
        startPage();
        List<ShopTask> list = shopTaskService.selectShopTaskList(shopTask);
        return getDataTable(list);
    }

    /**
     * 导出任务管理列表
     */
    @PreAuthorize("@ss.hasPermi('net:shopTask:export')")
    @Log(title = "任务管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShopTask shopTask) {
        List<ShopTask> list = shopTaskService.selectShopTaskList(shopTask);
        ExcelUtil<ShopTask> util = new ExcelUtil<ShopTask>(ShopTask.class);
        util.exportExcel(response, list, "任务管理数据");
    }

    /**
     * 获取任务管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('net:shopTask:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(shopTaskService.selectShopTaskById(id));
    }

    /**
     * 新增任务管理
     */
    @PreAuthorize("@ss.hasPermi('net:shopTask:add')")
    @Log(title = "任务管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShopTask shopTask) {
        return toAjax(shopTaskService.insertShopTask(shopTask));
    }

    /**
     * 修改任务管理
     */
    @PreAuthorize("@ss.hasPermi('net:shopTask:edit')")
    @Log(title = "任务管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShopTask shopTask) {
        return toAjax(shopTaskService.updateShopTask(shopTask));
    }

    /**
     * 删除任务管理
     */
    @PreAuthorize("@ss.hasPermi('net:shopTask:remove')")
    @Log(title = "任务管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(shopTaskService.deleteShopTaskByIds(ids));
    }
}
